feat(remote): serve a model on a tailnet GPU machine - #333
volen-silo wants to merge 3 commits into
Conversation
f2dca4f to
78bf68b
Compare
78bf68b to
e186e9a
Compare
|
The red That job landed on which is exactly the three unexpected failures in this run ( The runner is repaired — torch is back to |
7285717 to
24e057b
Compare
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · 24e057b
Summary
Adds rocm remote (~7.8k lines, 31 files): provisions the CLI onto a GPU machine over SSH, serves a model there, and publishes the port onto a Tailscale tailnet, plus a containerised SSH test harness and CI lane. Needs work — the security design is genuinely good, but four added tests cannot fail when the code they guard breaks, and one harness line can expose a baked-in password beyond loopback. Verified: the trust model is loopback bind + per-session API key + tailnet-scoped tailscale serve — I confirmed the remote server is pinned to --host 127.0.0.1 --require-api-key (mod.rs:478-493), that funnel is never invoked (only serve --bg --tcp=, publish.rs:176-186), that the key travels on ssh stdin not argv and is stored 0600 with a path-traversal-guarded session id, that shell_quote covers every user value and is proven against a real sh, and that host trust is delegated to the user's own ssh config with BatchMode=yes (fails closed, no silent TOFU) — the README states all of this plainly, so code and documented model match; on the revert question I checked every added test individually and four fail it (below), while the rest are tied to real functions via a ScriptedTransport that hard-errors on unmatched commands; I refuted a reported "remote skips signature verification" concern by reading install.sh (a pinned release key is present, so public_keys is non-empty and the signature gate fires on the remote too); I ran cargo fmt --check (clean) as my one permitted check, so the red check is not formatting — the two plausible candidates I can argue from the source are the unguarded readiness loop in run-e2e.sh:141-144 and the first-ever activation of @requires-docker scenarios on the required e2e lane via E2E_INCLUDE_DOCKER: "1", but I could not read the CI logs and will not call it flake without them. Blocking: 4 · Non-blocking: 5.
🚫 Blocking (must fix before merge)
tests/remote-ssh/run.sh:84-85 — the container is started with docker run -d -p "127.0.0.1:${PORT}:22" ... || docker run -d -p "${PORT}:22" .... The fallback drops the loopback prefix and publishes sshd on all interfaces, and the image ships a real password account (Dockerfile:39-45: a fixed username/password with PasswordAuthentication yes) whose password is committed to this public repository. On any host where the 127.0.0.1: publish form fails, this silently exposes a guessable-password shell on the LAN for the container's lifetime — on a CI runner or a contributor's laptop. run-e2e.sh:84 correctly uses the loopback bind with no fallback. Fix: drop the || fallback so a failed loopback bind is a hard error.
tests/e2e-cucumber/tests/e2e/remote_steps.rs:283-305 (scenario at features/remote.feature:58-64) — remote-09 is titled "Checking a machine's health never installs anything on it", but its When step deliberately uses no container, so ssh fails at the transport layer before remote_doctor reaches bootstrap::locate_cli (the step's own comment says so). then_doctor_installed_nothing accepts "could not reach" as a pass, and then_doctor_points_at_serve wraps its only assertion in if said.contains("only reads"), which never holds here — a permanently dead assertion. If remote_doctor were changed to call ensure_ready_with(...) and silently provision on a health check, this scenario would pass unchanged. Fix: give it a reachable container with no rocm binary so locate_cli's refusal actually fires, and make then_doctor_points_at_serve unconditional.
tests/remote-ssh/run-e2e.sh:195-198 — attach is the one stateful step whose effect is never checked. serve (line 167) and stop (line 206) both cross-check the container's real tailscale serve status --json; attach only asserts the printed strings "Endpoint re-published" and "not restarted". The preceding step withdraws the endpoint out of band, so this is precisely where re-publishing matters — yet an attach that printed those lines without re-publishing would go undetected, because the following stop reports success either way and the final expect_absent '"8000"' passes trivially. Fix: add serve_config="$(in_container tailscale serve status --json)"; expect_contains "the endpoint is back" '"8000"' "${serve_config}" right after the attach call.
apps/rocm/src/remote/mod.rs:1413-1425 — serve_sends_the_key_over_stdin_when_it_starts_the_model never calls serve(). It invokes transport.exec_with_stdin(..., Some("k")) itself, then asserts ScriptedTransport recorded the Some("k") it was just handed — exec_with_stdin pushes stdin unconditionally, so the assertion cannot fail. Its comment claims to guard "the caller actually supplies it", but reverting the real call site at mod.rs:270 from Some(&api_key) to None leaves this green. The command-shape half is already covered by mod.rs:1023. Fix: make serve() accept a &dyn Transport so the real orchestration can be driven through ScriptedTransport, or delete the test rather than leave a false guarantee on the credential path.
Non-blocking
apps/rocm/src/remote/provision.rs:130-131— the comment "the remote can repeat every check this machine made" is overstated:ROCM_CLI_SIGNING_PUBLIC_KEY_PATH/PEMis not forwarded, so an operator using a private-mirror key gets the remote verifying against the pinned production key instead — a hard failure, not a downgrade, but a confusing one. Forward the key vars, or narrow the comment.apps/rocm/src/remote/provision.rs:155—ROCM_CLI_ARCHIVE={remote_dir}/{asset}is the only unquoted interpolation into a remote command in the whole module;assetcomes from parsing the installer'sdownloaded:line. Not exploitable today, but it breaks the otherwise-uniformshell_quotediscipline.apps/rocm/src/remote/transport.rs:24-28andtailnet.rs:248-252— both#[cfg_attr(not(test), allow(dead_code))]comments say "remove this attribute in the change that adds the serve path"; this PR is that change. Leaving them will mask genuinely dead code added later.apps/rocm/src/remote/transport.rs:238-240—ConnectTimeout=10bounds only the handshake; there is noServerAliveInterval/ServerAliveCountMaxand no wall-clock bound onwait_with_output(), so a connection that drops mid-command hangs the CLI indefinitely, including instatus's polling loop.tests/remote-ssh/run-e2e.sh:141-144— the sshd readiness loop falls through after 15s with no success check, unlike the equivalent loop inrun.sh:108-113which hard-fails with a clear message. A slow container start surfaces as a confusing discovery-assertion failure instead; this is my leading in-diff candidate for the red check.
|
Addressed all 4 blocking findings and 4 of 5 non-blocking findings from the automated review; skipping one non-blocking item as a follow-up. Blocking
Non-blocking
Verification
Also replied to and resolved the two CodeQL threads: alerts #778/#779 already report |
9af9830 to
7327243
Compare
|
🔴 Automated review · pr-review-watcher · 486054f This automation posts comments only. It never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer. SummaryAdds 🚫 Blocking (must fix before merge)1. ensure_public_service_has_endpoint_key(host, endpoint_key_file.is_some(), false)?;
It is reachable, not merely theoretical, because the two values are computed by different tests: This also repeats prior finding 1's shape: the comment on the line above ("enforce the invariant here too rather than relying on every future caller having done so") claims the invariant is enforced, and only half of it is. Fix: 2. publish: publish::publish_state(transport, record.tailnet_port, record.remote_port).ok(),
This is the same defect class as prior blocking finding 2, one layer up and still present. The inconsistency is visible within the same function: forty lines earlier the very same code path carefully separates Fix: carry the error rather than dropping it — make the field 3. async fn then_doctor_points_at_serve(world: &mut E2eWorld) {
let said = said(world);
if said.contains("only reads") {
assert!(said.contains("rocm remote serve"), "{said}");
}
}If the output does not contain This is the standing test-vacuity failure mode, and it is in the remediation itself: commit 6f3a81e ( Fix: drop both escape hatches — assert Non-blocking
|
|
Addressed the second review round. Blocking finding 1 — Blocking finding 2 — Non-blocking items — none skipped, all five addressed:
Verification (local, on top of the branch's current merge with
Commits: One open item, not part of this review round's findings: |
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · de914c0
This automation posts comments only. It never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer.
Summary
Adds rocm remote (serve/attach/stop/status/doctor/targets) driving a tailnet GPU machine over SSH, plus a containerised SSH test lane — Needs work. Verified: ran cargo test -p rocm --bin rocm remote:: (126 passed, 0 failed); confirmed both prior blocking findings are genuinely fixed — the Funnel classifier now checks AllowFunnel before the forward lookup and both publish and withdraw bail naming tailscale funnel --tcp=<port> off, and the tailscale prerequisite is hoisted above the install branch with a revert-sensitive test; also confirmed the credential is delivered over stdin (never argv) and the diff carries no internal leaks or injected instructions. Two new defects in the remediation commits, both verified against source. Blocking: 2 · Non-blocking: 5.
🚫 Blocking (must fix before merge)
1. apps/rocm/src/remote/provision.rs:195-218 — signing-key precedence is the inverse of install.sh, and the doc comment claims otherwise.
signing_env_fragment_from matches pem_env first and only falls back to path_env. install.sh:99-110 (resolve_public_keys) does the opposite: it returns ROCM_CLI_SIGNING_PUBLIC_KEY_PATH if set and only falls through to _PEM when it is not. The doc comment at provision.rs:184-186 asserts "an explicit _PEM is forwarded as-is and takes precedence, matching install.sh's own resolution order" — that is factually false, on the selection of a signature trust root. With both variables set locally, a remote provision verifies against a different key than a local install.sh run would; the failure surfaces as "the remote rejected the build we fetched for it", which points at the artifact rather than at the key.
There is a second, sharper edge in the same function: std::env::var(..).ok() yields Some("") for a variable set to the empty string, whereas install.sh's [ -n ... ] treats empty as unset. So ROCM_CLI_SIGNING_PUBLIC_KEY_PEM="" together with a real _PATH makes this code forward an empty _PEM and silently drop the operator's explicit key, and the remote then falls back to the pinned production keys — the operator's chosen trust root is discarded with no diagnostic.
Fix: check path_env before pem_env (or, if the inversion is deliberate, correct the comment and say why), and treat an empty value as unset on both branches. The new test an_explicit_pem_is_forwarded_as_is_and_wins_over_a_path (provision.rs:407-421) currently encodes the wrong order, so it must change with the code — it is why this slipped through. Add a case asserting the order that install.sh actually implements.
2. apps/rocm/src/remote/transport.rs:359-370 — the deadlock fix consults the stdin-writer error before the outcome it now has in hand, discarding ground truth.
wait_with_output() returns first and output already holds ssh's exit code, stdout and stderr. The code then does writer.join()...?? before the SSH_TRANSPORT_FAILURE (255) check at :379, so a write error on the payload aborts the call and throws the captured outcome away. The relevant write error is BrokenPipe: if the child exits and closes stdin before the writer thread is scheduled, write_all gets EPIPE. Moving the write onto a thread widened that window rather than narrowing it — previously the write happened inline immediately after spawn, whereas now the main thread blocks in wait_with_output while the writer waits to be scheduled.
The consequence lands on the one caller that uses this path, serve_with_transport (mod.rs:286): instead of the purpose-built "could not reach {dest} over ssh: {stderr}", an unreachable host can produce "failed to send input to {dest}: Broken pipe", which mod.rs:288-300 then wraps as "lost contact ... so it may or may not be running" and clears the freshly minted key — telling the user the model's state is unknown when the transport in fact reported 255 and nothing started. The call-site comment "this fails on a broken pipe while sending the key ... so the model's state is genuinely unknown from here" was true before the fix and is now stale.
Fix: evaluate the 255 check and build RemoteOutcome from output first; only surface a writer error when the process outcome does not already explain the failure (treat ErrorKind::BrokenPipe as advisory once output is in hand). While there, join the writer on the wait_with_output error path too — today it is dropped and detached.
Non-blocking
apps/rocm/src/remote/transport.rs:201-216and:655-672— the remote-path guard's stated rationale is wrong: the remote argument is built asformat!("{destination}:{remote_path}"), so it can never start with-and scp cannot read it as an option; keep the check but fix the comment and the test comment, or a future reader re-derives the same wrong mechanism.apps/rocm/src/remote/provision.rs:284-294—create_dirfollowed byset_permissions(0o700)leaves a umask window, contradicting the adjacent comment's "0700 keeps the contents unreadable"; this repo already has the atomic pattern inapps/rocm/src/dash.rs:255-266(DirBuilder::new().mode(0o700)), which even documents why..github/workflows/ci.yml:652-691— the newremote-sshjob runscargo build -p rocmwith noactions-rust-lang/setup-rust-toolchainstep and no rust cache, unlike every other cargo job in this workflow; a cold uncached build of this workspace against the 30-minute timeout is a plausible cause of the single failing check, but I am inferring that from the workflow source and cannot confirm it — no lane names were available to me, and the un-merged base may equally explain it.tests/remote-ssh/fake-tailscale.sh— the fake only ever emits{"TCP": ...}, neverAllowFunnel,ForegroundorServices, so the exposure classifier's safety branches (the subject of the prior blocking finding) are proven only againstScriptedTransportfixtures, not against anything shaped like the real daemon.apps/rocm/src/remote/mod.rs:747— theFunnelAllowedstatus line leads with "no", but that state is also reached when our own forward is live (Funnel is checked first and short-circuits); phrase it as an exposure warning rather than a "not published" answer.
de914c0 to
486054f
Compare
|
Addressed the review on Both blocking findings fixed, each reproduced first.
All five non-blocking items fixed, including the scp guard rationale (the remote argument is prefixed with the destination, so that half is a shape check rather than a safety one) and the Funnel status line. One finding I did not take. The CI lane suggestion assumed the missing toolchain explained the red check. It did not — Beyond the review, worth flagging:
Local: full workspace tests, clippy |
|
CI status: 20 of 21 checks green, including The one red check,
Flagging rather than fixing: a dash regression is unrelated to this PR and belongs in its own change. Happy to pick it up separately if that is useful. |
pr-review-watcher · de914c0 — superseded, withdrawn.
Both blocking findings from that round are genuinely fixed at the current head, and each was re-verified here rather than taken from the summary: the signing-key precedence now matches the install script in both order and empty-value handling, pinned by a test that fails when the order is reverted; and a cleanly failed transport is now reported as a failure rather than as indeterminate, pinned by a regression test whose payload size makes the condition deterministic instead of timing-dependent.
On the earlier CI-lane point: the author is right and that finding was wrong. It asserted a cause for a red check that this automation had no way to confirm, and should have been stated as an inference or not at all.
A fresh review of the current head is posted separately.
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · 486054f
This automation posts comments only. It never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer.
Both findings from the previous round are genuinely fixed, and the earlier change request has been withdrawn. Blocking: 3 · Non-blocking: 5. Three new issues at this head, two of them the same two defect classes one layer away from where they were fixed. Full detail is in the review comment on this PR.
1. The API-key guard is bypassed at one of its four call sites. ensure_public_service_has_endpoint_key is passed a hardcoded false for requires_api_key in apps/rocm/src/main.rs, while the real value is already in scope and the other three call sites pass it. Reachable, because the guard's two inputs are computed by different tests — one by file existence, one by file validity — so an existing-but-invalid key file is exactly the case the new branch was added to catch, and it spawns an unauthenticated listener instead. The comment above the line says the invariant is enforced here; only half of it is. Fix: pass the real value, and add a test for a present-but-empty key file on a service that requires one.
2. A definite remote failure is reported as "the machine could not be asked." In apps/rocm/src/remote/mod.rs, publish_state(...).ok() discards two materially different errors into one: transport failure, and the remote answering with a non-zero exit and its own stderr. The user is told the machine was never reached when it in fact replied with an actionable reason. This is the same class as the finding just fixed in the transport layer, one layer up — and the same function separates reached-but-failed from never-reached forty lines earlier, which is also what the module docs describe. Fix: carry the error instead of dropping it, and pin the distinction with a test.
3. A test step asserts nothing when its guard does not match. In tests/e2e-cucumber/tests/e2e/remote_steps.rs, the step passes unconditionally unless the output contains a particular phrase, and its partner step carries a matching escape hatch. Together the scenario can go green having checked only that the command exited non-zero. The commit in this round that made the container reachable removed the reason those fallbacks existed but left them in place, so they are now dead permissiveness that will hide the coverage disappearing. Fix: drop both escape hatches so an unexpected path fails loudly.
486054f to
b014f52
Compare
|
History rewritten: 19 commits squashed to 3, and rebased onto current The three commits are feature / tests / docs. Further review rounds will amend these rather than stack more fix commits on top. The three blocking findings — all verified, and all older than the last round.
All five non-blocking items are also fixed, including a Beyond the named findings, I swept the diff for each defect class rather than just the sites reported. That turned up one more instance of the same collapse: the session-listing path built a Verified locally on the rebased tree: full workspace tests, clippy |
Dismissing this as superseded. Re-reviewed at b014f52: all three counts are resolved and I verified them rather than taking the summary on trust - the managed-spawn guard now receives the record's own flag (confirmed load-bearing by reverting the call site in a scratch copy, which makes the new test fail), the reached-but-failed versus never-reached split is restored and pinned by a test asserting the two render differently, and all 23 then-steps were walked for any input under which no assertion runs. A separate, newly-found instance of the same fail-open class is filed as a fresh change request; this older one is retired so only one objection is live.
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · b014f52
This automation posts comments only. It never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer.
Summary
Adds rocm remote: discover GPU machines on a tailnet, provision them over SSH, serve a model there and publish its port, plus a containerised SSH test lane and docs. Needs work — all three counts of the standing objection are genuinely resolved, but the author's own sweep for the "collapse a failure into a weaker state" class missed one instance, and it sits on the same security gate as count 1. Verified: read all three commit messages whole from the raw objects (57/52/28 lines, signatures intact, company identity and DCO sign-off present); ran a scratch-copy revert experiment reverting the apps/rocm/src/main.rs guard call site to the hardcoded false and ran cargo test -p rocm --bin rocm a_managed_spawn_refuses_an_invalid_key_file — it FAILED, so that test is genuinely load-bearing rather than passing either way; confirmed publish_state(..).ok() is gone and its replacement is pinned by a test that asserts the two outcomes render differently; walked all 23 #[then] steps in remote_steps.rs and found no remaining vacuous-pass path; leak scan over the diff clean (no internal hostnames, gateways, cluster names or registry paths; ROCM_TEST_APK_REPOS defaults empty and the documented example uses the public Alpine CDN); no prompt-injection content found. Blocking: 1 · Non-blocking: 5.
🚫 Blocking (must fix before merge)
apps/rocmd/src/lib.rs:3239 — the API-key requirement is silently dropped, and written back to disk, when a record read fails. supervise_service rebuilds the record from scratch (ManagedServiceRecord::new starts requires_api_key false) and restores the flag from disk with load_managed_services(paths).unwrap_or_default(). That call returns Err on a real, informative failure — read_dir, the per-entry ?, or fs::read on any single record file (note it skips unparseable JSON, so Err means an I/O failure, not a corrupt record). .unwrap_or_default() turns that into "no service ever required a key". The next line falls back to key-file presence, which is absent precisely when a service has been stopped — the case the code's own comment three lines above calls out. Both signals then read false, ensure_public_service_has_endpoint_key at :3250 passes, and the service comes back up on a loopback bind with no authentication even though the user launched it with --require-api-key.
Why this blocks rather than being a nit: it is reachable without exotic conditions (a record file deleted by a concurrent rocm services stop between read_dir and fs::read is enough — ENOENT), it fails open on a security gate, and record.write() at :3256 persists the weakened record, so the damage is permanent: every later rocm services restart is disarmed too. That is verbatim the outcome the adjacent comment says must not happen — "rebuilding a record here without restoring it would not just skip the check now — it would write the weakened record back and disarm every later rocm services restart as well." In user-facing terms this is the same sentence as count 1 of the standing objection: a service the user asked to protect starts unprotected. The PR introduces these lines, so it is not pre-existing.
Fix: propagate instead of defaulting — load_managed_services(paths)?. The function already returns Result<()> and uses ? freely a few lines up (paths.ensure()?, fs::create_dir_all(...)?), and failing closed is this file's own stated preference ("an unreachable service is recoverable, an anonymous public one is not"). Add a test that drives the real call site — supervise_service checks the guard before record.write() and before command.spawn(), so the same technique a_managed_spawn_refuses_an_invalid_key_file_on_a_service_that_requires_one uses in the rocm copy works here — asserting both that it refuses and that the on-disk record is not rewritten with requires_api_key: false.
Non-blocking
.github/workflows/ci.yml:669— the new lane is the only job-levelif: needs.changes.outputs.heavy == 'true'in the file; every otherheavygate is step-level, and the file documents at :1066 why job-level gating stalls the merge queue for a required check. Harmless while this lane is not a required check; worth confirming that is the intent before it becomes one.apps/rocm/src/remote/mod.rs:903—stop()collapses a transport error and a non-zero remote exit into one bool, and the bail names no reason, unlike the withdraw branch immediately above which interpolates{error}. Nothing is misreported (unlike count 2), but the remote's own words are available and dropped.apps/rocm/src/remote/mod.rs:839,867— no test ever callsattach()orstop(); onlyrender_stoppedis tested, with hand-picked booleans. Deleting the earlybail!s so the record is removed on an unconfirmed teardown would pass every test in the file.apps/rocmd/src/lib.rs:5228,7571— the guard tests here call the function directly with literals; neither real call site is driven, so a future miswiring in this copy would go undetected. Therocmcopy does it properly and is the model to follow.apps/rocm/src/remote/transport.rs:195— ~14 literal spaces mid-sentence in a user-facing error message ("would be read as an option"), an editing artefact.
On the standing objection
Count 1 — "a service the user asks to protect with an API key can start UNPROTECTED when the key file is empty or unreadable"; originally "ensure_public_service_has_endpoint_key is passed a hardcoded false for requires_api_key in apps/rocm/src/main.rs". RESOLVED. Both call sites (apps/rocm/src/main.rs:5978 and :15818) now pass record.requires_api_key, and key_present is validity-filtered through endpoint_api_key_from_file rather than mere file existence. The requested test exists and I verified it is load-bearing rather than taking the claim on trust: on a scratch copy with the call site reverted to the hardcoded false, a_managed_spawn_refuses_an_invalid_key_file_on_a_service_that_requires_one fails.
Count 2 — "a real remote failure is reported to the user as merely unreachable"; originally "publish_state(...).ok() discards two materially different errors into one". RESOLVED. The .ok() is gone; observe now calls publish::observe(...), which preserves the reached-but-failed versus never-reached split the same function already made forty lines earlier. Pinned by a_remote_that_answers_about_publishing_is_not_reported_as_one_that_was_never_asked, which asserts the remote's own stderr reaches the status line and that the two cases do not render identically — it would fail against the old .ok().
Count 3 — "one end-to-end test passes without checking anything"; originally "the step passes unconditionally unless the output contains a particular phrase, and its partner step carries a matching escape hatch". RESOLVED. Both named steps now assert unconditionally, with inline comments recording why the guard was removed. I walked all 23 #[then] steps individually looking for any input under which no assertion runs — conditional asserts with no else, early returns, silently-falling-through matches, defanging unwrap_or — and found none.
The block is withdrawn on all three counts. It is replaced by the single new blocking finding above.
On the author's sweep claim. The claim that the diff was swept for this defect class beyond the reported sites, finding one further instance, does not hold: apps/rocmd/src/lib.rs:3239 is a fourth instance, in the same subsystem as count 1. A second, milder instance sits at apps/rocm/src/main.rs:18075, where the uninstall plan's remote-session warning is defaulted away on an I/O error — that one mirrors the pre-existing style on the line above it and is informational only, so it is not called out separately.
Why this will recur (and the cheap prevention). The cause is the codebase inviting the wrong conclusion, not reviewer error: load_managed_services(paths).unwrap_or_default() appears twice in this diff with identical shape, once feeding a security gate and once feeding a printed warning, and nothing at the call site distinguishes them. A competent reader sweeping for this class will keep classifying the security-gate use as benign best-effort, exactly as the author's sweep did. The prevention is one line: at :3239, use ? and add a comment saying this read may not be best-effort because its result arms the guard below — sitting next to the comment already there that explains why the flag must be restored at all.
On CI. The check-run conclusions at this head are counts only (failure 2, pending 4, skipped 1, success 21) with no lane names available, so no outcome is attributed to any named job here; the workflow observation above is read from the YAML, and I cannot confirm from this checkout whether any particular lane is red or why.
Check-run conclusions at this head were failure 2, pending 4, skipped 1, success 21 when the review started, and failure 2, pending 3, skipped 1, success 22 when this was filed. The earlier change request on this PR has been dismissed as superseded, so this is the only objection of ours that is live.
juhovainio
left a comment
There was a problem hiding this comment.
I went through this pretty thoroughly given how security-sensitive it is (SSH as the control channel, credential handling, remote provisioning, the signing chain). Overall the design is careful and the corner cases are unusually well tested — most of what I went looking for to poke holes in turned out to already be handled and covered by a dedicated test.
I did find two real issues in the session cleanup/lifecycle code in remote/mod.rs, left as inline comments below. Neither is huge on its own, but both can end up destroying the only copy of an API key for a model that's still running and reachable on the tailnet — which, given the whole point of this feature is auth-gating that exposure, seems worth fixing before merge.
I also ran down the specific claims in the PR description, since they're the load-bearing ones and worth a human not having to re-derive:
- The API key really does only travel over stdin. It never shows up in the
sshcommand line on this machine, and the remote reads it withread -roff stdin before anything execs — checked both directions. --require-api-keyis a hardcoded literal in the one function that builds the remote serve command, so there's no path where a remote session comes up without it.- The install.sh download-only / install-from-archive split does forward the checksum and signature, and the remote re-verifies both exactly like a normal install. One thing worth knowing, not a bug: on the nightly channel, signature verification is optional unless a key is explicitly configured — that's how install.sh already behaved before this PR, and it's called out in a comment, not something new here.
- The signing-key env var resolution in
provision.rs(_PATHbefore_PEM, empty treated as unset, a forwarded key blanking the remote's own_PATH) matches install.sh's own resolution logic exactly, which is the part that actually matters — a mismatch would mean the local and remote sides verify against different trust roots. - Ownership of a published tailnet port is established before the port is claimed and re-checked before it's torn down, with a test that specifically catches "the withdraw command exited 0 but the port is still published" — so teardown really is confirmed rather than assumed.
- Passwordless sudo is checked (
sudo -n true) before any privileged install command runs, ahead of the actual install call, so a machine that would prompt for a password fails fast with a clear message instead of hanging the SSH session. ROCm install also stays opt-in behind--install-rocm; the health-check path never triggers it on its own.
On CI: the two failing checks (E2E tests and E2E tests (rad3 R9700)) are both unrelated to this PR. The first is the known EAI-7960 dashboard flake already being fixed separately in #241, the second is a runner GPU-preflight/resource-contention failure. Neither traces back to this diff.
The PR is explicitly marked "ready for review, not for merge" with two items the author already flagged as needing a real tailnet/GPU to confirm, so I'm not re-flagging those — just the two cleanup-path bugs below.
| } | ||
| } | ||
|
|
||
| session::clear_key(paths, session_id); |
There was a problem hiding this comment.
session::clear_key runs unconditionally here, even when leftovers isn't empty (i.e. the withdraw or services stop call just above it failed). That means when this cleanup path itself fails, the model can still be running and its endpoint can still be published on the tailnet, but the only copy of its API key just got deleted.
That's the opposite of the policy this same file uses a bit earlier for discover_started_service's failure path ("The key stays... deleting our only copy would leave a service the user can find but cannot call"). Can this gate on leftovers.is_empty() the same way, and report the key's path in the leftover message when it doesn't clear it? stop() already does the equivalent gating, so there's a pattern to follow here.
There was a problem hiding this comment.
Fixed in ceff4f8f. clear_key is now gated on leftovers.is_empty(), and when anything could not be undone the key's path is appended to the leftovers instead of the key being deleted — so the message names it the way the discover_started_service branch already did.
You were right that there was a pattern to follow and this was the odd one out: discover_started_service keeps the key and says where it is, stop_with_transport gates on !force, and this was the only one of the three that deleted unconditionally.
Both directions are tested now: the existing both-steps-fail test asserts the key survives and that its path is reported, and a new test asserts a clean unwind still drops it, so the gate cannot drift into leaving orphaned credentials behind instead.
| // to every machine on the tailnet. | ||
| let session_id = RemoteSessionRecord::id_for(peer_host, request.remote_port); | ||
| let api_key = rocm_core::generate_endpoint_api_key(); | ||
| session::store_key(paths, &session_id, &api_key).context( |
There was a problem hiding this comment.
session_id is deterministic from peer_host + remote_port, and remote_port defaults to a fixed value, so re-running serve against the same target/port (e.g. trying a different model on the same box before stopping the first one) silently overwrites the previous session's key here, and its record on success too.
If the new attempt then fails, the cleanup path a bit further down ends up deleting the key entirely (see the other comment), leaving the still-running earlier session both unreachable and untracked. This is the same "ownership before claim" property publish/withdraw enforce for the tailnet-forward layer — worth having the same guard here: check for an existing record at this session_id first, and refuse (or require --force) rather than overwriting silently.
There was a problem hiding this comment.
Fixed in ceff4f8f, and this one was worse than it looked — thank you for connecting it to the cleanup path, because the damage does not even need that path.
serve now establishes the name is free before it mints anything, the same way publish refuses a port that already forwards elsewhere. The check sits at the top of serve_with_transport, ahead of the readiness probe, so a refusal costs no round trip and cannot provision a machine the command then declines to use. It checks the key file as well as the record, since the two are written at different moments.
The plainer sequence, all defaults, was: serve again on the same box → the key file is overwritten before anything starts → the start fails because the first session still holds the port → the failure path deletes the shared key outright. The user reads "failed to start the model" as "nothing happened", while the first session is still serving on a published endpoint that can no longer be called.
Chasing it turned up a second problem in the remedy: a key with no .json record beside it cannot be reached by rocm remote stop at all, because load_all enumerates *.json only — so "stop it first" would have been advice that provably fails, on exactly the state the guard detects. The refusal now branches: with a record it points at stop; with a credential alone it says an earlier attempt got far enough to mint a key and not far enough to record what it started, and names the file. Tests cover both branches and assert nothing is sent to the machine before the refusal.
That in turn surfaced a third: rocm remote doctor reads an Examination, which carries platform, GPU, driver and ROCm facts but no services, processes or ports — so it can never answer "is a model running here". Two places were advising it for that question, including describe_leftovers. Both now advise ssh <target> -- rocm services list.
b014f52 to
15e42f0
Compare
|
Pushed Found while verifying the two reported bugs
Verification
Still unverified, unchanged from the description: no real tailnet has carried traffic, no real GPU has loaded a model, and nothing here has spoken to a live Not addressed, and worth a decision
|
Addressed in 15e42f0 — see the inline replies and the summary comment.
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · 15e42f0
This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer.
Summary
Adds rocm remote: discover tailnet GPU machines over SSH, health-check and provision them, serve a model there, and publish its loopback port onto the tailnet via Tailscale — plus a containerised OpenSSH test lane and docs. Outcome: Needs work. Verified: ran one targeted check — the four new rocmd unit tests (cargo test -p rocmd --lib, 4 passed); the full workspace suite, the e2e suite and the container lanes were not run here. I confirmed by reading the live files that the previously-reported registry read is now propagated with ? rather than defaulted, that the API key is passed only on stdin and never interpolated into a command string, that SSH host-key checking is nowhere weakened, that install-side checksum verification is unconditional and precedes use of the archive, and that the Funnel fixtures use port 443 (a port Funnel can actually serve). No prompt-injection content was found anywhere in the changed files. The working copy under review was left unmodified (git status clean, HEAD unchanged); no experiment touched it. Check outcomes at review start: 25 success, 1 failure, 1 pending, 1 skipped. Blocking: 2 · Non-blocking: 5.
🚫 Blocking (must fix before merge)
1. apps/rocm/src/remote/publish.rs:264 — a port already held by a Tailscale HTTPS/HTTP handler is classified as free, and publishing silently destroys it.
RawTcpHandler (publish.rs:108) deserializes only TCPForward. Tailscale's serve config represents a TLS-terminating handler as a TCP entry carrying HTTPS/HTTP with no TCPForward, so handler.and_then(|handler| handler.tcp_forward.clone()) yields None and classify returns PublishState::Absent — the same bucket as "nothing is there". publish treats Absent as free to take and issues tailscale serve --bg --tcp=<port> tcp://127.0.0.1:<remote_port>.
This is precisely the harm the module's own doc comment says must not happen: "tailscale serve overwrites whatever holds a port without complaint, so checking afterwards is too late... A second session reusing a port would silently take the first one's endpoint away." The Foreign state exists to refuse exactly this, and the HTTPS case walks straight past it. It is not theoretical: the default --tailnet-port is 8000 (remote/mod.rs:47), and tailscale serve --bg 8000 on that port is an ordinary thing for a user to have already done.
The added test an_https_handler_on_the_port_is_not_a_forward (publish.rs:556) asserts classify(r#"{"TCP": {"8000": {"HTTPS": true}}}"#, 8000, 11434) == PublishState::Absent, so it pins the wrong behaviour as correct. Its name and comment are literally true — an HTTPS handler is not our forward — but Absent does not mean "not our forward", it means "free to take", and that conflation is the bug.
Fix: parse HTTPS/HTTP (and ideally TerminateTLS) on RawTcpHandler, and classify "a handler exists at this port but is not our matching TCPForward" as Foreign { forwards_to: "an existing HTTPS/HTTP handler" } in all three nestings (TCP, Foreground, Services). Update the test to assert Foreign, and correct the SERVE_CONFIG_KEYS doc comment at publish.rs:40-48, which currently states the HTTPS/HTTP handler is never read because "this design never asks Tailscale to terminate TLS on our behalf" — true of what we create, irrelevant to what someone else already created.
2. apps/rocmd/src/lib.rs:3260 — the call-site test claims to catch miswiring of the API-key guard, but only one direction of miswiring can fail it.
The fix itself is correct: load_managed_services(paths) is now propagated with ? instead of .unwrap_or_default(), the key-file fallback clause is gone, and record.requires_api_key is restored from the registry before the guard runs. I verified this in the live file and ran the four new tests; they pass at this head.
The problem is the coverage claim. The helper's doc comment (lib.rs:5299) states it exists because a literal-argument unit test "cannot catch the defect that actually happened twice in this crate's history — the guard being wired up with the wrong value at its call site". Only the false direction is defended. Mutate line 3260 to record.requires_api_key = true; — hardcoding the requirement rather than reading it — and all four new tests still pass, because no test drives supervise_service for a service that never required a key. That mutation is not hypothetical: the comment immediately below line 3260 records that an over-broad requirement (the || key-file-is-present clause) already shipped once in this PR and "refused them with the wrong remediation". The remediation removed the defect but shipped no test that would stop it returning.
Fix: add a third case using the existing seed_registry / supervise_at_the_guard helpers — seed a record with requires_api_key: false and no key file, and assert supervise_at_the_guard does not refuse. While there, also mutation-proof the existing.service_id == record.service_id half of the .any(...) predicate: with a single seeded record, dropping that comparison changes nothing, so a second service's requirement leaking onto an unrelated one is currently undetectable. Seeding two records (one requiring a key, one not) covers both in a single test.
Non-blocking
apps/rocm/src/remote/transport.rs:457— theexplained_by_the_commanddemotion is never exercised: every test that reaches thewrittenmatch uses a destination that exits 255, which returns earlier, so dropping&& !output.status.success()(the fail-open direction, which would let a truncated API-key write read as success) breaks no test.apps/rocm/src/remote/doctor.rs:154—is_stateful_sequenceis a live path with no coverage; forcing it to returnfalseleaves all 16 module tests green, so a broken guard would silently split a multi-step fix that depends on a shared subshell.apps/rocm/src/remote/mod.rs:567—remote_serve_commandputs the positional model before the flags with no--separator, so a flag-shaped model name is parsed as a flag by the remote'srocm serve; it fails closed, but the error misattributes the cause..github/workflows/ci.yml:669— the new lane gates at job level (if: needs.changes.outputs.heavy == 'true') unlike every sibling job here, which gate per step; harmless today, but it would stall the merge queue on a non-heavy PR if this check ever becomes required.tests/e2e-cucumber/features/remote.feature— nothing in the suite makes a request against a published endpoint, so the--require-api-keyinvariant is asserted only as a string in CLI output, never at the traffic level; likely inherent to the stand-in remote, but worth stating in the PR text as a named gap.
On the standing objection: the single count filed at the earlier commit — the API-key requirement being silently dropped and written back to disk when a registry read failed — is resolved, verified against the live code rather than taken on the author's account. The registry read now propagates instead of defaulting, the key-file-presence fallback is gone, the requirement is restored from the registry alone, and the guard runs before the record is written; both requested tests exist and drive the real call site. That change request has been dismissed as superseded, so the two findings above are the only objections of ours that are live. Blocking item 2 is a narrower successor, not a restatement.
15e42f0 to
357130b
Compare
|
Pushed 1 — a port held by an HTTPS/HTTP handler read as free. Correct, and the test was pinning it. The test is rewritten to assert The 2 — the call-site test only defended one direction. Also correct. Added a case seeding two records, one requiring a key and one not, so the Worth recording how that went, because the first attempt failed in the way your finding predicts. I asserted on the service manifest appearing, as proof the guard had admitted the call — and both mutations you named survived it, because the seeding helper had already written that manifest, so the poll proved nothing. The working version decides on what the call returns, identifying the guard's refusal by its message rather than by the bare fact of an error. Confirmed by applying both mutations: each fails the test now, and it passes unmutated. One more in the same area, not reported, found while acting on the first finding. Also corrected a comment in Non-blocking items: none addressed in this push, and taking them in turn rather than as a block — the Verification: |
Addressed in 357130b — see the reply comment.
357130b to
10aaa17
Compare
|
🔴 Automated review · pr-review-watcher · 357130b This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer. Scope note: this review was made against commit SummaryAdds 🚫 Blocking (must fix before merge)
The test's comment states the guarded failure is a torn record that Replace the whole mechanism at Fix: make the test observe the intermediate state. Either spawn two writer threads racing on the same Non-blocking
|
10aaa17 to
9c8edd9
Compare
|
🔴 Automated review · pr-review-watcher · 10aaa17 This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer. Scope note: this review judges commit SummaryAdds 🚫 Blocking (must fix before merge)
The test's name and its own leading comment claim it guards atomicity ("a torn record is skipped by Why it passes regardless: the test writes twice, sequentially, in one thread. Nothing races and nothing is interrupted, so no torn file is ever produced. Assertion 1 ( Concrete fix — either of:
The whole point of the surrounding design comment is that a half-written record silently hides a live, published endpoint. That is exactly the failure this test is the only guard against, and it is not guarding it. Non-blocking
|
juhovainio
left a comment
There was a problem hiding this comment.
I read through the new rocm remote subsystem (discovery, provisioning, serve, publish/teardown) plus the touch-points on existing serve/services list/install.sh, using a full checkout of the branch rather than just the diff so I could trace the surrounding code.
Overall this is solid work — the trust-chain, injection-safety, and backwards-compatibility claims in the PR description all held up when I actually read the code, not just the comments. I found two real bugs worth fixing before merge, plus a handful of smaller things. Left as inline comments below.
The two that matter:
- An unattended remote install can proceed on a platform the failure-mode catalog has never evaluated, because
install::assess()only looks atmatchedfindings and never checksout_of_scope. - A race in the session-key file writes: two concurrent
rocm remote servecalls against the same target+port can both pass theexists()check, and the loser's cleanup path can delete the winner's key out from under a live, published session.
Everything else is minor: a couple of TOCTOU-shaped gaps that are narrow but real, a shell command that depends on ; behaving like && (already flagged as fragile in the code's own comment), a remote staging directory with no explicit permissions, and two CI gating nits on the new remote-ssh job.
One thing I want to call out as not a problem, since the PR explicitly raises it: the FunnelAllowed guard being unreachable at the default port 8000 is correctly implemented and not a bug — it's a real design question (document it / change the default / drop it) rather than something to fix in code.
| /// | ||
| /// Split from the doing so the judgement is testable on its own — the part | ||
| /// worth being sure about is what gets refused, not what gets run. | ||
| pub(crate) fn assess(report: &DiagnoseReport, passwordless_sudo: bool) -> Option<Refusal> { |
There was a problem hiding this comment.
Major: assess() only inspects report.matched, never report.out_of_scope. rocm_core::diagnose deliberately distinguishes "nothing wrong" from "this platform isn't covered by the catalog" — but here they're treated the same. On an out-of-scope platform with passwordless sudo available, this returns None and the install proceeds unattended on a machine the catalog admits it never evaluated. That directly undercuts the stated goal of this module ("installing ROCm is opt-in and gated on the failure catalog"). Also untested — the shared test helper hardcodes out_of_scope: None. Low exposure today since install.sh only supports Linux/x86_64, but the gate should still check out_of_scope.is_some() and refuse.
There was a problem hiding this comment.
Fixed in b2c5dd94.
Worth noting before the detail: this thread's anchor has drifted. These are new files, so the whole file is one addition hunk and GitHub re-anchors a comment by offset rather than marking it outdated — the line this comment now sits beside is not the line it was written about. The code you quoted has changed.
assess() now asks out_of_scope first, before findings and before sudo, and returns a new Refusal::NotEvaluated carrying the catalog's own sentence.
Your diagnosis was right and the reason it is easy to miss is worth recording: diagnose() returns an empty matched in two opposite situations — a machine that was checked and is clean, and a platform with no catalog entries, where nothing runs at all (diagnose.rs forces matched empty whenever out_of_scope is set). One is a verdict, the other is the absence of one, and only out_of_scope separates them. rocm-core says as much in prose: "nothing was checked -- this is not a clean bill of health."
Checked first rather than last because the ordering is itself a claim: fixing sudo does not make an unevaluated platform installable, so a sudo refusal would send the user to do work that cannot help.
On the test gap you flagged — covered at two levels. At the guard, by running the real diagnose() against an examination the catalog has no checkers for, rather than hand-building a report with out_of_scope: Some(..); what makes a platform out of scope is the catalog's coverage rule, and a hand-built report would assert our idea of that rule instead of the catalog's. At the call site, by driving ensure_ready_with(.., install_rocm = true) and asserting the transport is never asked to run install driver — the guard returning a refusal is the outcome, but not issuing the install is the mechanism.
| /// The key is checked as well as the record, because they are written at | ||
| /// different moments: a session that failed between minting its key and writing | ||
| /// its record leaves the key alone on disk. | ||
| pub(crate) fn exists(paths: &AppPaths, session_id: &str) -> bool { |
There was a problem hiding this comment.
Major: exists() (checked before a session claims a target+port) and the later write are not atomic — no O_EXCL, just create+truncate. Two concurrent rocm remote serve calls against the same target+port can both pass this check and then both write/overwrite the key file. If the loser's port-claim then fails, its cleanup path (clear_key, further down this file) deletes the key file outright — which can be the winner's key if the write race went the other way. publish.rs explicitly re-verifies ownership after a destructive/claiming action; this file doesn't apply that same recheck to the key file, so a live, published session can silently lose its own API key.
There was a problem hiding this comment.
Fixed in b2c5dd94. Same caveat as the other thread: these are new files, so GitHub re-anchored this comment by offset rather than marking it outdated — the code beside it now is not the code it was written about.
You were right, and the window is wider than the description suggests. exists() is called before bootstrap::ensure_ready_with, deliberately, so a refusal costs no round trip — but the key write happens after provisioning, which the module's own docs describe as taking minutes when it installs a CLI. So the gap between check and write is not a few instructions, it is the entire readiness probe.
The fix makes the credential write be the claim rather than adding another check: store_key now creates with create_new — O_EXCL on unix, CREATE_NEW on Windows — with 0o600 applied at creation rather than tightened afterwards. One syscall decides ownership, so there is no second step to race and no lock artefact that could itself leak.
Your point about the loser's cleanup is what shaped the error handling. A bare boolean would have lost the distinction between "the name is taken" and "the disk is full", so the failure carries a distinct NameAlreadyHeld that the call site downcasts: on that path nothing of ours is on disk, so serve bails with no unwind and — the part that matters — no clear_key, because the credential belongs to the winner.
exists() is kept, but its doc comment now says it diagnoses rather than decides. It earns its place by being cheap and by telling a recorded session from a stray credential, which need different remedies.
On testing it: an end-state assertion cannot see this defect, because both runs write to the same name and an overwrite leaves an identical filesystem — which is why the previous test here passed with the mechanism absent. The assertion is on return values instead: sixteen concurrent serves, exactly one Ok. That holds under every interleaving and is only true when the claim is indivisible.
| // port, not a forward, so it would happily tear down whatever is on that | ||
| // port — including something another tool or another person put there after | ||
| // our session was recorded. | ||
| match publish_state(transport, tailnet_port, remote_port)? { |
There was a problem hiding this comment.
Minor: ownership is checked once here, but the actual teardown (transport.exec(&withdraw_command(...)), a few lines down) isn't re-checked immediately before it runs. tailscale serve ... off acts on the port, not a specific forward, so if a third party republishes something else to this port in that narrow window, this still tears it down and reports Ok. Narrow, but the check-then-act gap is real given how carefully the rest of this function documents wanting to avoid exactly that.
There was a problem hiding this comment.
Not addressed yet. Agreed the check-then-act gap is real and narrow: tailscale serve ... off acts on the port, so a third party republishing in that window gets torn down and reported Ok.
Worth noting the same function already re-reads state after the withdraw to confirm it, so the shape for a pre-teardown recheck is there. The honest limit is that a recheck narrows the window rather than closing it — only the daemon could make it atomic — so it is a real improvement and not a fix.
| /// anyway, since the publish widens who can reach it. | ||
| fn remote_serve_command(remote_cli: &str, request: &ServeRequest) -> String { | ||
| let mut command = format!( | ||
| "IFS= read -r ROCM_SERVE_API_KEY; export ROCM_SERVE_API_KEY; \ |
There was a problem hiding this comment.
Minor: this command joins IFS= read -r ..., the export, and rocm serve with ;, not &&. The broken-pipe-suppression logic in transport.rs (search run_with_piped_io) explicitly says its safety depends on the read running first and the command's exit status reflecting that — but with ;, the compound's exit status is whatever rocm serve returns, not the read. The code comment there already flags this coupling as something to recheck if this command is ever reordered; swapping to && would let the shell itself enforce the invariant instead of relying on downstream validation.
There was a problem hiding this comment.
Not addressed yet, and I think this is the least minor of the five.
You are right that the coupling is real and currently held by prose. run_with_piped_io demotes a BrokenPipe only when the command also failed, and its comment states the dependency explicitly: the read runs first, so a broken pipe means the read never finished, which means the command cannot have exited 0. With ; the compound's status is whatever rocm serve returns, so the shell is not enforcing what the comment claims — the ordering is.
&& would move that invariant from a comment into the shell, which is the right direction. Holding off only because it changes the remote command shape and the container lanes assert on it; it should land with a test that observes the exit status rather than the string.
|
|
||
| let remote_dir = REMOTE_STAGING; | ||
| transport | ||
| .run(&format!("mkdir -p {remote_dir}")) |
There was a problem hiding this comment.
Minor: the remote staging directory is created with plain mkdir -p, no explicit mode. The local counterpart (search create_restricted_dir) is a carefully-justified nonce-named 0700 directory specifically to avoid another user on the same box reading or racing the pushed archive/checksum/signature before verification. Worth the same discipline server-side, especially on a shared remote box with a permissive umask.
There was a problem hiding this comment.
Not addressed yet, and the asymmetry you point at is the argument for it: the local side goes to some trouble with a nonce-named 0700 directory precisely because another user on the box could race the artifact before verification, and the remote side has the same exposure with none of the care.
Worth pairing with the mode being set at creation rather than tightened afterwards, since mkdir -p then chmod leaves the same umask window the local helper avoids.
| # No GPU, no ROCm, no tailnet: the remote's `rocm` and `tailscale` are | ||
| # stand-ins that answer in the shapes the real tools do. | ||
| name: remote control channel (containerised) | ||
| runs-on: ubuntu-latest |
There was a problem hiding this comment.
Minor: every other job gated on heavy in this workflow (build-and-test, test, windows-build-and-test) has needs: [changes, clippy, prek], specifically so a fast lint failure short-circuits before spending build time. This new job only has needs: changes, so it'll run its full 30-minute container+cargo cycle even when clippy or prek would have failed instantly.
There was a problem hiding this comment.
Not addressed yet. Confirmed: every other heavy-gated job carries needs: [changes, clippy, prek] and this one has only needs: changes, so it burns the full container and cargo cycle on runs a lint failure would have ended in seconds.
This is also a prerequisite for the other open question on this lane — whether it should be a required check — because the gating has to be right before anything depends on it.
| # stand-ins that answer in the shapes the real tools do. | ||
| name: remote control channel (containerised) | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 |
There was a problem hiding this comment.
Minor: the other heavy-gated jobs in this file also carry if: github.event_name != 'workflow_dispatch', so a manual dispatch stays a fast loop. This job doesn't have that guard, so a manual dispatch will now also pull in this 30-minute containerized job.
There was a problem hiding this comment.
Not addressed yet, and it belongs with the needs: change above rather than separately — both are about this job not matching the conventions of its siblings in the same file.
|
🔴 Automated review · pr-review-watcher · 9c8edd9 This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer. SummaryAdds 🚫 Blocking (must fix before merge)
Non-blocking
|
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · 9c8edd9
This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer.
First, the previous round's blocking finding is genuinely resolved at this head, and confirmed rather than taken on trust: deleting the staging-file-plus-rename now makes the replacement test fail, where before the same mutation left the module entirely green. That objection is closed.
The production code held up well under adversarial review at this head. Three new counts, all of the same shape — a test that does not constrain the branch it names, each confirmed by deleting that branch and watching the suite stay green. Two of the three guard security properties. The full report, including five non-blocking observations, is in the review comment on this PR.
1. The peer-ordering test cannot observe the sort it is named for. Parsing collects peers into a map keyed by node public key and then sorts them by host name. In the fixture, the keys and the host names happen to rise together, so map iteration alone already yields the expected order. Deleting the sort call outright left all fifteen tests in that module passing. The sort is correct production code guarding against unordered output, and nothing pins it. Inverting the fixture so key order and host order disagree — while leaving the expected vector unchanged — makes the test real. Please add a line saying the keys are deliberately in the opposite order to the hosts, so a later editor does not tidy the fixture back into agreement and silently re-blind it.
2. The path-traversal test for credential clearing asserts nothing. The clearing helper refuses ids that fail validation, which is what stops an attacker-shaped session id deleting a file outside the sessions directory. The test calls it with a traversal id under a comment saying clearing one is a no-op rather than a delete somewhere else, and then makes no assertion at all — the function returns unit and swallows the I/O result, so the line passes vacuously. Deleting the validation guard, so the helper unconditionally removes the traversed path, left every test in the module passing. Plant a file at the resolved escape target, call the helper with the traversal id, and assert the planted file still exists.
3. The destination-refusal test leaves half of its guard unpinned. The check refuses a destination whose whole token begins with a hyphen, or whose host half does. Every hostile case in the test is caught by the host-half disjunct alone, because each either contains no separator or puts the hyphen after it. Deleting the whole-token disjunct left all 156 tests in that area passing. The shape that needs it is a destination whose host half is clean but whose whole token is read positionally as an option — which is precisely the local-command-execution case the function's own doc comment describes. Adding one such case to the hostile list closes it.
Each of these gates rather than sitting in the non-blocking list for the same reason: a weak test is not strengthened after merge, and in counts 2 and 3 the branch left unpinned is the one carrying the security property. The mechanisms themselves are implemented correctly today; the objection is only that nothing would notice if they stopped being.
Check-run conclusions this review worked from, at this head: 18 success, 1 failure, 1 pending, 1 skipped; re-read immediately before filing, the pending had resolved to success, giving 19 success, 1 failure, 1 skipped — the failure count is unchanged. Conclusion counts only; no per-lane detail was available, so nothing here is attributed to any named job, no claim is made about what the failure is, and nothing above rests on it.
Adds `rocm remote`: discover GPU machines on a tailnet, check their health, install what they are missing, serve a model on one, and reach it from any machine on the tailnet. SSH is the control channel, not the data path. Everything that inspects or changes the remote goes over SSH; the inference traffic does not. `rocm serve` binds loopback on the GPU machine as it always has, and the machine then tells its own Tailscale daemon to forward a tailnet port to it. Nothing runs locally, so the endpoint outlives the command that created it and answers from any machine rather than only the one that started it. Two touch points with existing behaviour: - `rocm serve --require-api-key` makes a loopback bind authenticated anyway. Publishing the port makes "loopback means only this machine" false while leaving the bind address unchanged, which would otherwise put an unauthenticated model endpoint on the tailnet. The key travels to the remote on stdin, never in a command line, since both machines expose command arguments in their process tables. - `install.sh` grows download-only and install-from-archive modes. Provisioning never copies the local binary — that only works when both machines share an OS and CPU, and when they do not the copy still lands and still looks installed. The remote fetches its own build; if it cannot reach the release host, this machine fetches one for the remote's platform and pushes it with its checksum and signature so the remote repeats every check. Signing-key selection matches install.sh's own order exactly, and a forwarded key blanks the remote's own path so the two machines cannot end up on different trust roots. `rocm services list --json` is the machine-readable listing the orchestration reads back, applying the same liveness filter as the table. Signed-off-by: Eugene Volen <Eugene.Volen@amd.com>
The unit tests drive a scripted stand-in, which proves the control flow but assumes the real tools behave a certain way. These check that assumption against a real OpenSSH server in a container — no GPU, no ROCm, no tailnet, since the remote's `rocm` and `tailscale` are stand-ins. - `tests/remote-ssh/run.sh` checks the tool contracts: argument handling, exit-code propagation, a credential delivered on stdin and absent from the command line, file copy, batch-mode refusal, the shape Tailscale Funnel takes in the serve config, and that withdrawing a published endpoint actually removes it. - `tests/remote-ssh/run-e2e.sh` drives the built binary through the whole flow: discover, probe, serve, publish, reconcile status, re-publish after an out-of-band withdrawal, tear down, and refuse to publish over a Funnel-exposed port. - 14 cucumber scenarios in `features/remote.feature`; the six needing a host on the other end of a real SSH connection carry `@requires-docker` and skip with a reason where no container runtime exists. - Both scripts run on a new `remote control channel (containerised)` CI lane, gated on the `heavy` path filter. The Funnel fixtures use 443, not the default tailnet port: Funnel serves only 443, 8443 and 10000, so an AllowFunnel entry on any other port is a document the daemon cannot produce and a test against it proves nothing. `resolve` takes an `Included` struct rather than a row of same-typed bools, so a mis-ordered argument cannot silently change which set runs. Signed-off-by: Eugene Volen <Eugene.Volen@amd.com>
Covers the `rocm remote` surface, and in docs/testing.md how to run the two container-backed lanes — including the ROCM_TEST_APK_REPOS escape hatch a network that intercepts TLS needs to build the fixture image. Signed-off-by: Eugene Volen <Eugene.Volen@amd.com>
9c8edd9 to
b2c5dd9
Compare
|
Pushed. Both findings from your review are fixed.
The Four invariants nothing currently observes, each demonstrated by deleting the mechanism and watching the suite stay green rather than by argument:
All four are cross-boundary, and none is in the diff's behaviour — they are gaps in what is defended. Whether they belong in this PR or as follow-ups is your call: at ~10.8k lines across 31 files it is past what one review pass covers, and you have already said as much. On your five minors — none addressed yet. One I would flag as more than minor: |
Both findings addressed in b2c5dd9 — see the reply comment. The five minors are not yet addressed.
|
🔴 Automated review · pr-review-watcher · b2c5dd9 This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer. SummaryAdds a Previous round
The One correction to the author's reasoning: the loser skipping Of the three previously-reported non-constraining tests, one is fixed and two are not. The 🚫 Blocking (must fix before merge)
Non-blocking
Check-run conclusions were re-read immediately before posting and are unchanged from the counts stated above. |
siloteemu
left a comment
There was a problem hiding this comment.
🔴 Automated review · pr-review-watcher · b2c5dd9
This automation never files a GitHub approval, so no approving review will appear here whatever the outcome — the merge decision stays with a human reviewer.
Blocking: a test does not constrain the mechanism it names.
parsing_orders_peers_and_strips_the_magicdns_trailing_dot in apps/rocm/src/remote/tailnet.rs names the peer ordering and asserts a specific host sequence, but cannot fail when the ordering is removed. The peers map is keyed by nodekey, and the fixture's keys are already in host-alphabetical order, so iterating the map yields exactly the asserted sequence before the explicit sort ever runs. Deleting the sort leaves every test in that module green — measured, not argued. No scenario covers peer ordering either, so nothing else catches it.
This is the same defect class reported in the previous round for this test, and it is unchanged at this head. A weak test is rarely strengthened after merge, and once it lands CI certifies the gap.
Suggested fix: permute the fixture so nodekey order and host order disagree — give the alphabetically-last host the alphabetically-first nodekey — so the assertion depends on the explicit sort. Two further assertions in the same test are indexed by position and would become genuinely order-dependent at the same time.
The two blocking findings from the previous round are both genuinely resolved, with the fixes independently constrained by tests; the remaining observations are non-blocking and are in the review comment on this PR.
juhovainio
left a comment
There was a problem hiding this comment.
Followed up on the still-open minor items from my last pass, to weigh whether any of them should actually block merge.
mod.rs:604 (; instead of &&) — the one I'd push for before merge.
The broken-pipe-suppression logic in transport.rs decides "key write failed → state unknown, don't clear the key" specifically because it assumes the read running first means a broken pipe implies nothing started. That assumption is currently true only because of prose, not because the shell enforces it — ; doesn't. Today it's safe (the command shape is pinned and tested). The risk is entirely about the next person who touches that remote command: if it's ever reordered without noticing this coupling, the failure-classification logic silently goes wrong on the credential path, and nothing catches it because the existing test asserts on strings, not exit status. This is a cheap fix (; → &&) for a real regression trap in the API-key path — worth doing now rather than as follow-up.
provision.rs:160 (staging dir, no explicit 0700).
Only matters on a shared multi-user remote box with a permissive umask. Worst case is a local user on that box reading (or, with a lax umask, racing) the pushed archive/checksum/signature before verification — but the signature gate still has to be defeated for it to matter, so the practical impact is information disclosure or a corrupted install, not a bypass. Low risk for the common single-tenant GPU box case. Worth fixing for parity with the local 0700 helper, but not merge-blocking.
publish.rs:449 (no ownership recheck before teardown).
Even the requested fix only narrows the window rather than closing it — only the daemon could make it atomic. There's no available fix that meaningfully changes the risk profile, so leaving it open costs nothing beyond what a fix would have left anyway. Fine as a documented limitation.
ci.yml:666-667 (missing needs: and dispatch guard).
Zero correctness/security risk, pure CI cost. Fine as follow-up.
Net: the two Major issues (install.rs out-of-scope gate, session.rs key race) are fixed and verified against the live code — cargo test -p rocm --bin rocm remote:: passes 162/162 including the new tests. Of the remaining minors, only the ;/&& one sits in a security-relevant path; I'd like that one addressed before merge, and I'm fine with the other three as follow-up.
juhovainio
left a comment
There was a problem hiding this comment.
Approving with the minor findings above - please address them to an extend that seems good in the scope of this PR
tests/e2e-cucumber/expectations.tomlfor the fixed ticket ID and removed/narrowed any now-stale xfail rows. — n/a, no bug fix; no xfail rows affected.Summary
Adds
rocm remote: discover GPU machines on your tailnet, check their health, install what they are missing, serve a model on one, and reach it from any of your machines.SSH is the control channel, not the data path. Everything that inspects or changes the remote goes over SSH. The inference traffic does not:
rocm servebinds loopback on the GPU machine as it always has, and the machine then tells its own Tailscale daemon to forward a tailnet port to it. Nothing runs locally, so the endpoint outlives the command that created it and answers from any of your machines rather than only the one that started it.Ready for review, not for merge. Two things still need a real tailnet and a real GPU to confirm — see "Not verified" below.
Why this shape
The alternative was a local
ssh -Ltunnel. Publishing from the remote instead means no local process to supervise, no tunnel PID to track, and an endpoint that survives the terminal that made it. The cost is a hard dependency on Tailscale for serving, and an endpoint that is tailnet-wide rather than point-to-point — which is what drove the one change to existing behaviour below.Changes existing behaviour
rocm serve --require-api-key.servegrants an API key only to non-loopback binds, reasoning that loopback means "only this machine can reach it". Publishing the port makes that false while leaving the bind address unchanged — which would put an unauthenticated model endpoint on the tailnet. The new flag makes a loopback bind authenticated anyway; remote sessions always set it. Local serving is unchanged.The key travels to the remote on stdin, never in a command line, since both machines expose command arguments in their process tables.
install.shdownload-only and install-from-archive modes. Provisioning never copies the local binary — that only works when both machines share an OS and CPU, and when they do not the copy still lands and still looks installed. The remote fetches its own build; if it cannot reach the release host, this machine fetches one for the remote's platform and pushes it with its checksum and signature so the remote repeats every check. Splitting the trust chain across two machines must not shorten it.rocm services list --json— the machine-readable listing the remote orchestration reads back, applying the same liveness filter as the table.Non-obvious decisions
install.shexactly. Both resolve_PATHbefore_PEM, and both treat an empty value as unset. What they choose between is the trust root a signature is verified against, so the two disagreeing would let a remote provision accept a build a local install would reject — surfacing as a rejected artifact rather than a key mismatch. A forwarded key also blanks the remote's own_PATH, so a value the far side exports for itself cannot beat the one we sent.ROCM_REMOTE_SSH_CONFIGnames an alternative ssh config.sshresolves~/.ssh/configfrom the account database rather than fromHOME, so there was otherwise no way to point the CLI at a different one. Added while building the end-to-end harness, which could not run without it; independently useful for anyone with a per-project ssh config.Test plan
cargo test --workspace --all-targets,cargo clippy --workspace --all-targets -- -D warnings,cargo fmt --check,prek run --all-files,scripts/smoke_local.py— all pass.tests/e2e-cucumber/features/remote.feature. Eight cover discovery, refusals and the session list. Six need a host on the other end of a real SSH connection, so they carry a@requires-dockergate and skip with a reason where no container runtime exists.tests/remote-ssh/run.sh— 21 checks of the tool contracts against a real OpenSSH server in a container: argument handling, exit-code propagation, a credential delivered on stdin and absent from the command line, file copy, batch-mode refusal, the shape Tailscale Funnel takes in the serve config, and that withdrawing a published endpoint actually removes it.tests/remote-ssh/run-e2e.sh— 25 checks driving the built binary through the whole flow: discover, probe, serve, publish, reconcile status, re-publish after an out-of-band withdrawal, tear down, and refuse to publish over a Funnel-exposed port.remote control channel (containerised)CI lane, gated on theheavypath filter.On a network that intercepts TLS, the container lanes need plain-HTTP package mirrors —
docs/testing.mddocuments theROCM_TEST_APK_REPOSescape hatch.Not verified
tailscaleis a stand-in on both sides of every harness, so publish/withdraw are exercised but no inference request crosses a tailnet. Needs a real two-node tailnet.tailscale servecommand surface. Shapes follow Tailscale's documented CLI and theServeConfigstruct, and the parsing contract is pinned against a stateful stub — but nothing here has spoken to a real daemon.rocmis a stub.Open question for review
The Funnel guard is unreachable at the default port. Tailscale Funnel serves only 443, 8443 and 10000. The default tailnet port is 8000, so
PublishState::FunnelAllowed— a state variant, four refusal arms, a status line, six unit tests and two container lanes — can only be reached by someone passing--tailnet-port 443(or 8443/10000). That is not a hole: Funnel exposure is per-port, so a Funnel on 443 does not expose a session published on 8000. But it is a lot of machinery behind an opt-in flag, and Funnel is not mentioned in any user-facing doc. Worth deciding whether to document it, default differently, or drop it.Risk
Medium. The
rocm remotesurface is entirely new and additive. The two touch points with existing behaviour areserve's new opt-in flag (loopback serving is unchanged when it is absent) and the installer's new modes (the existing path is untouched). Reviewers may reasonably want the installer change looked at separately given its place in the signed-release trust chain — happy to split it out.